import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Headers,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { GetUserDto } from './dto/get-user.dto';
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Post('/create')
  create(@Body() createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }

  @Get('/list')
  findAll(@Query() query: GetUserDto) {
    //查询条件 page size username limit
    console.log(query);
    return this.userService.findAll(query);
  }
  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.userService.findOne(+id);
  }
  @Patch('/update/:id')
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(+id, updateUserDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.userService.remove(+id);
  }
  @Get('/logsCount/:id')
  async logsCount(@Param('id') id: string): Promise<any> {
    const res = await this.userService.logsCount(+id);

    return res;
  }
  @Get('/logs/:id')
  findLogs(@Param('id') id: string) {
    return this.userService.findLogs(+id);
  }
}
